<template>
  <div class="search-bar">
    <el-input
      :value="value"
      @input="handleInput"
      placeholder="请输入数据名称"
      prefix-icon="el-icon-search"
      clearable>
      <el-button 
        slot="append" 
        type="primary" 
        @click="$emit('search')">
        搜索
      </el-button>
    </el-input>
  </div>
</template>

<script>
export default {
  name: 'SearchBar',
  
  props: {
    value: {
      type: String,
      default: ''
    }
  },
  
  methods: {
    handleInput(val) {
      this.$emit('input', val);
    }
  }
};
</script>

<style scoped>
.search-bar {
  position: fixed;
  top: 50px;
  left: 0;
  right: 0;
  background: white;
  padding: 15px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
  z-index: 999;
}

.search-bar >>> .el-input__inner {
  border-radius: 8px;
  background: #f5f5f5;
  border: none;
}

.search-bar >>> .el-input-group__append {
  border-radius: 0 20px 20px 0;
  background: white;
  border: 1px solid #dcdfe6;
  border: none;
}

.search-bar >>> .el-input-group__append .el-button {
  color: #409EFF;
  background: transparent;
  border: none;
  font-weight: 500;
}

.search-bar >>> .el-input-group__append .el-button:hover {
  color: #66b1ff;
}
</style>

